import { Application } from 'egg';
import * as pageFindPlugin from 'mongoose-paginate';
export default (app: Application) => {
  const mongoose = app.mongoose;
  const collectSchema = new mongoose.Schema({
    // 平台(h5, miniApp, web, app)
    platform: String,
    // 业务
    business: String,
    // 页面
    page: String,
    // 事件(visit, click)
    event: String,
    // 参数
    param: String,
  }, { timestamps: true });
  collectSchema.plugin(pageFindPlugin, { limit: 10 });
  collectSchema.index({ platform: 1, business: 1, page: 1, event: 1 });
  return mongoose.model('Collect', collectSchema);
};
